class CreateSubmissions < ActiveRecord::Migration
  def self.up
    create_table (:submissions) do |t|
        t.column :name, :string, :limit => 80
        t.column :submitted, :datetime, :null => false 
        t.column :team_id, :integer, :null => false
        t.column "file", :text,  :default => "", :null => false
        t.column "language", :string, :default => "", :null => false, :limit => 20
        t.column "status", :string, :default => "GRADING", :null => false, :limit => 80
    end

    user = Team.find(:all, :conditions => { :name => "player"})[0]
    for i in (0..3)
       submission = Submission.new()
       submission.name = "problem_"+i.to_s()
       submission.submitted = DateTime.now()
       
       user.submissions << submission 
    end
    user.save
  end

  def self.down
    drop_table :submissions
  end
end
